home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
sos3-2.lha
/
bin
/
sos-CC
< prev
next >
Wrap
Text File
|
1992-02-13
|
4KB
|
123 lines
#!/bin/sh
# --------------------------------------------------------------------------
# Copyright 1992 by Forschungszentrum Informatik (FZI)
#
# You can use and distribute this software under the terms of the licence
# you should have received along with this program.
# If not or if you want additional information, write to
# Forschungszentrum Informatik, "STONE", Haid-und-Neu-Strasse 10-14,
# D-7500 Karlsruhe 1, Germany.
# --------------------------------------------------------------------------
# 'sos-CC - 03/09/91 - Dietmar Theobald'
#
# sos-CC <command> [-o <object_file>] [-schema <schema>] [-no_scp] [-keep_scp]
# <args>...
#
# 'sos-CC' performs C++ compilations of SOS method implementations and schema
# interface modules.
# The actual compilation is done by executing the arguments with the
# modifications listed below, i.e. the first argument is expected to be the
# name of the C++ compiler.
# After a successful compilation the generated object file is associated with
# a schema using 'sos-sil'. To this end an object file must be named on the
# command line by "-o <object_file>".
#
# Two kinds of source files may be compiled with 'sos-CC':
# - schema interface modules ("*_sos.c"), and
# - method implementations ("*.c", "*.cc", "*.C").
#
# The corresponding schema is given either explicitly using the '-schema'
# option, or implicitly by looking for a single schema file in the directory
# containing "*_sos.c", or "*.c" ("*.cc", "*.C") respectively.
#
# In case of compiling method implementations contained in '<p>.c' an
# intermediary source file '<p>_scp.c' is maintained in the same directory as
# '<p>.c'. This intermediary file is regenerated by the SOS preprocessor
# 'sos-scp' each time '<p>.c' changes, or if '<p>_scp.c' does not exist.
# The intermediary file is used as input for the compilation.
# That preprocessing can be suppressed by the option '-no_scp'.
# If the option '-keep_scp' is enabled, the file '<p>_scp.c' is kept after
# the compilation, removed otherwise.
#
test="${SOSCONTAINER?}"
tmp_scp='+'
while [ $# -gt 0 ] ; do
case "$1" in
-no_scp) no_scp='+' ;;
-keep_scp) tmp_scp='' ;;
-o) [ "$outfile" ] && {
echo >&2 '*** sos-CC: multiple "-o" options'; exit 1
}
shift ; outfile="$1" ;;
-schema) [ "$schema" ] && {
echo >&2 '*** sos-CC: multiple "-schema" options'; exit 1
}
shift ; schema="$1" ;;
*_sos.c) [ "$infile" ] && {
echo >&2 '*** sos-CC: multiple source files'; exit 1
}
infile="$1" ;;
*.c |\
*.C |\
*.cc ) [ "$infile" ] && {
echo >&2 '*** sos-CC: multiple source files'; exit 1
}
infile="$1"
suffix="`expr match "$1" '.*\.\([^.]*\)'"
call_scp='+' ;;
*) args="$args '$1'" ;;
esac
shift
done
[ "$no_scp" ] && { call_scp=''; tmp_scp='' ;}
[ "$infile" ] || { echo >&2 '*** sos-CC: source file missing'; exit 1 ;}
[ "$outfile" ] || { echo >&2 '*** sos-CC: object file missing'; exit 1 ;}
in_dir=`dirname "$infile"`
[ "$schema" ] || {
set $in_dir/*.sos ""
if [ $# -gt 2 ] ; then
echo >&2 "*** sos-CC: several SOS schema files in $in_dir"
exit 1
elif [ -f "$1" ] 2> /dev/null ; then
schema=`basename "$1" .sos`
else
echo >&2 "*** sos-CC: no SOS schema file in $in_dir"
exit 1
fi
}
[ "$call_scp" ] && {
im_file=`expr match "$infile" "\(.*\).$suffix"`_scp.c
if [ "$tmp_scp" ] ; then
del_file="$im_file"
else
set `ls -L -t $infile $im_file 2> /dev/null` ""
[ "$1" = "$infile" ] || call_scp=''
fi
[ "$call_scp" ] && { echo "+ sos-scp $schema -o $im_file $infile"
sos-scp $schema -o $im_file $infile || exit 1
}
infile="$im_file"
}
eval `echo "echo + $args -o $outfile $infile"`
eval `echo "$args -o $outfile $infile"`
status=$?
[ $status -eq 0 ] && {
echo "+ sos-sil $schema -a $outfile"
sos-sil $schema -a $outfile || {
[ "$SOSC_BOOTING" ] || { rm -f $outfile $del_file; exit 1 ;}
echo "(error ignored during bootstrap)"
}
}
rm -f $del_file
exit $status